import re
my_dict = ({'CREATE_TITLE_GOLD_COST':r'{ 0 0 0 0 0 0 }',
            # 'FAITH_CONVERSION_PIETY_MINIMUM':'-99999',
            # 'MAX_FEMALE_REPRODUCTION_AGE':'99',
            # 'MIN_ROYAL_COURT_TIER':'\"duchy\"',
            #'BASE_FERTILITY':'1000',
            'MINIMUM_HIRING_COST_MULTIPLIER':'0',
            'SCHEME_MIN_SUCCESS_GROWTH':'100',
            'FOCUS_ADULT_COOLDOWN_MONTHS':'2',
            # 'MAX_DREAD':'1000',
            #'DEFAULT_OWNER_DISCOVERY_CHANCE':'0.05',
            # 'MINIMUM_FAITH_SIZE_FERVOR_MODIFIER':'0.1',
            'UNRAISED_LEVY_REGIMENTS_SPEED':'4000',
            #'REGIMENT_MONTHLY_REINFORCE_SPEED':'0.1',
            'MAX_ATTACKER_BATTLES_WAR_SCORE':'1000',
            'MAX_DEFENDER_BATTLES_WAR_SCORE':'1000',
            'WAR_ATTACKER_COMBAT_MAX_SCORE':'1000',
            'WAR_DEFENDER_COMBAT_MAX_SCORE':'1000',
            #'MIN_HEIR_TO_FIND':'5',
            #'OUTBREAK_NEIGBHOR_CHECK_STEPS':'2',
            'MOVEMENT_SPEED_RETREAT':'12',
            'MOVEMENT_SPEED':'9',
            #'FLEET_SPEED':'45',
            'COUNTY_MOVEMENT_ATTRITION_PERCENTAGE':'0',
            'MINIMUM_COUNTY_MOVEMENT_ATTRITION':'0',
            'MINIMUM_COMBAT_WIDTH':'10000',
            #'NUM_PER_TIER':'{ 0 0 0 0 0 0 }',
            # 'MINIMUM_SUPPLY_LIMIT':'10000',
            #'IS_ON_THE_COUNCIL':'1000',
            #'ABOVE_LIMIT_MAX_LEVY_PENALTY':'0.5',
            #'ABOVE_LIMIT_MAX_TAX_INCOME_PENALTY':'0.5',
            #'BASE_REASSIGN_COST':'0',
            #'EXTRA_FERTILITY_FOR_FIRST_CHILD':'1000'
            })

# path
with open(r'ck3/game_path.txt', 'r', encoding='utf-8') as file:
    game_path = file.read()  # 读取全部内容到一个字符串
file_path = game_path + r"/game/common/defines/00_defines.txt"
# file_path = '/home/h/build/game-modify/hoi4/test.lua'

# read file

with open(file_path, 'r', encoding='utf-8') as file:
    content = file.readlines()

for key in my_dict:
    regular_express = key + ' ' + '=' + ' ' + '.*'
    target = key + ' ' + '=' + ' ' + my_dict[key]
    # print(regular_express, target)
    content = [re.sub(regular_express, target, line) for line in content]


# write back

with open(file_path, 'w', encoding='utf-8') as file:

    file.writelines(content)